<?php

namespace common\service;

use Yii;
use yii\helpers\Url;

class GlobalUrlService extends BaseService
{
    /**
     * 生成静态的资源链接.
     * @param $path
     * @param array $params
     * @return string
     */
    public static function buildStaticUrl($path,$params = [])
    {
        $domain = Yii::$app->params['domains']['static'];
        if( stripos($domain,"http") === false ){
            $domain = "http:".$domain;
        }
        $path = Url::toRoute(array_merge([$path],$params));
        return $domain.$path;
    }

    /**
     *
     * @param $path
     * @param array $params
     * @return string
     */
    public static function buildAdminUrl($path,$params = [])
    {
        $domain = Yii::$app->params['domains']['admin'];

        if(stripos($domain,'http') === false)
        {
            $domain = "http:".$domain;
        }

        return $domain . Url::toRoute(array_merge([$path],$params));
    }
}